import { Injectable, NestInterceptor, CallHandler } from "@nestjs/common";
import { Observable } from "rxjs";
import { map } from 'rxjs/operators';


interface data<T>{
    data: T
}

@Injectable ()
export class Response<T = any> implements NestInterceptor {
    intercept(context, next: CallHandler): Observable<data<T>> {
        return next.handle().pipe(map(data => {
            return {
                data,
                code: '200',
                message: '操作成功!'
            }
        }))
    }
}